package com.wmada.toolkit.ffmpeg.prop;

import com.alibaba.fastjson.JSONObject;

/**
 * @author will.ma
 * @date 2020-11-3
 */
public class AudioInfo {

    private Integer index;
    private String  codecType;
    private String  codecName;
    private String  codecLongName;

    private String  timeBase;
    private Float   startTime;
    private Integer bitRate;
    private Float   duration;

    private Integer sampleRate;
    private Integer channels;

    public Integer getIndex() {
        return index;
    }

    public void setIndex(Integer index) {
        this.index = index;
    }

    public String getCodecType() {
        return codecType;
    }

    public void setCodecType(String codecType) {
        this.codecType = codecType;
    }

    public String getCodecName() {
        return codecName;
    }

    public void setCodecName(String codecName) {
        this.codecName = codecName;
    }

    public String getCodecLongName() {
        return codecLongName;
    }

    public void setCodecLongName(String codecLongName) {
        this.codecLongName = codecLongName;
    }

    public Integer getSampleRate() {
        return sampleRate;
    }

    public void setSampleRate(Integer sampleRate) {
        this.sampleRate = sampleRate;
    }

    public Integer getChannels() {
        return channels;
    }

    public void setChannels(Integer channels) {
        this.channels = channels;
    }

    public String getTimeBase() {
        return timeBase;
    }

    public void setTimeBase(String timeBase) {
        this.timeBase = timeBase;
    }

    public Float getStartTime() {
        return startTime;
    }

    public void setStartTime(Float startTime) {
        this.startTime = startTime;
    }

    public Integer getBitRate() {
        return bitRate;
    }

    public void setBitRate(Integer bitRate) {
        this.bitRate = bitRate;
    }

    public Float getDuration() {
        return duration;
    }

    public void setDuration(Float duration) {
        this.duration = duration;
    }

    public static AudioInfo parse(JSONObject jsonObject) {
        AudioInfo info = new AudioInfo();
        info.index = jsonObject.getInteger("index");
        info.codecType = jsonObject.getString("codec_type");
        info.codecName = jsonObject.getString("codec_name");
        info.codecLongName = jsonObject.getString("codec_long_name");
        info.timeBase = jsonObject.getString("time_base");
        info.startTime = jsonObject.getFloat("start_time");
        info.bitRate = jsonObject.getInteger("bit_rate");
        info.duration = jsonObject.getFloat("duration");
        info.sampleRate = jsonObject.getInteger("sample_rate");
        info.channels = jsonObject.getInteger("channels");
        return info;
    }

}
